package thread2;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class futureTask1 {


    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MyCall1 myCall1 = new MyCall1();
        FutureTask<Integer> futureTask = new FutureTask(myCall1);
        new Thread(futureTask).start();
        Integer o = futureTask.get();
        System.out.println(o);
    }
}


class  MyCall1 implements Callable<Integer> {

    @Override
    public Integer call() throws Exception {
        Integer r = 0;
        for (int i = 0; i < 10; i++) {
            Thread.sleep(200);
            r+=i;
        }
       return r;
    }
}